﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ORMAC.CodeGen;
using ORMAC.UI.WPF.ViewModel;

namespace ORMAC.UI.WPF.Extensions
{
    /// <summary>
    /// extension class to convert DBObjects to their view models
    /// </summary>
    public static class DBObjectInfoExtension
    {
        public static DBObjectInfoEx ToVM(this DBObjectInfo dbObject)
        {
            return new DBObjectInfoEx{
                DBObject=dbObject,
            };
        }
        public static List<DBObjectInfoEx> ToVM<T>(List<T> dbObjects)
            where T:DBObjectInfo
        {
            return dbObjects.Select<T, DBObjectInfoEx>(s => new DBObjectInfoEx
            {
                DBObject=s,
            }).ToList<DBObjectInfoEx>();
        }
    }
}
